from django_redis import get_redis_connection
class MyRedis:
    def __init__(self):
        self.redis = get_redis_connection(alias='code')
    def setcode(self,phone,code):
        self.redis.setex(phone,60*2,code)
    def getcode(self,phone):
        val= self.redis.get(phone)
        if val:
            return val.decode("utf-8")
        return None

    def setword(self,word):
        self.redis.zincrby("word",1,word)

    def getword(self):
        return self.redis.zrevrange("word",0,5)

redistool=MyRedis()